import 'package:flutter/material.dart';

class PopupMenuButtonDemo extends StatefulWidget {
  const PopupMenuButtonDemo({super.key});

  @override
  State<PopupMenuButtonDemo> createState() => _PopupMenuButtonDemoState();
}

class _PopupMenuButtonDemoState extends State<PopupMenuButtonDemo> {
  String _currentMenuItem = 'Home';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('PopupMenuButtonDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(_currentMenuItem),
                PopupMenuButton(
                  onSelected: (String value) {
                      debugPrint('select:$value');
                      setState(() {
                        _currentMenuItem = value;
                      });
                  },
                  itemBuilder: (BuildContext context) => [
                    PopupMenuItem(child: Text('Home'),value: 'Home',),
                    PopupMenuItem(child: Text('Discover'),value: 'Discover',),
                    PopupMenuItem(child: Text('Community'),value: 'Community',),
                ])
              ],
            )
          ],
        ),
      ),
    );
  }
}